package com.zzr.zzrbackend.controller;

import com.zzr.zzrbackend.pojo.domain.TrackRecordListParam;
import com.zzr.zzrbackend.pojo.dto.CommonResult;
import com.zzr.zzrbackend.pojo.dto.param.TrackMessageParam;
import com.zzr.zzrbackend.pojo.dto.result.NoData;
import com.zzr.zzrbackend.pojo.dto.result.TrackRecordListResult;
import com.zzr.zzrbackend.pojo.dto.result.TrackRecordScheduleResult;
import com.zzr.zzrbackend.service.TrackRecordService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@RestController
public class TrackRecordController {
    @Resource
    TrackRecordService trackRecordService;

    @PostMapping("/api/track-record")
    public CommonResult<TrackRecordScheduleResult> schedule() {
        return trackRecordService.schedule();
    }

    @PostMapping("/api/track-record/list")
    public CommonResult<TrackRecordListResult> list(@Validated @RequestBody TrackRecordListParam trackRecordListParam) {
        return trackRecordService.list(trackRecordListParam);
    }

    @PostMapping("/api/track-record/parent")
    public CommonResult<TrackRecordScheduleResult> parentSchedule() {
        return trackRecordService.parentSchedule();
    }

    @RequestMapping(value = "/api/track/send", method = RequestMethod.POST)
    public CommonResult<NoData> seedTrackMessage(HttpServletRequest request,
                                                 @RequestBody TrackMessageParam trackMessageParam) throws Exception {
        return trackRecordService.seedTrackMessage(request, trackMessageParam);
    }
}
